package com.wzh.service;

import com.wzh.pojo.common.ResultE;
import com.wzh.dao.Classdao;
import com.wzh.pojo.Po.Classinfo;
import com.wzh.pojo.Req.ClassinfoReq;
import com.wzh.pojo.Resp.DataResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class Classser {
	@Autowired
	private Classdao classdao;

	public DataResp<List<Classinfo>> get(ClassinfoReq classinfoReq){
		DataResp<List<Classinfo>> dataResp=new DataResp();

		List<Classinfo> list =classdao.getAll(classinfoReq);
		int counts = classdao.getcounts(classinfoReq);
		String mes=list!=null? ResultE.SUCCESS.getMsg() :ResultE.ERROR.getMsg();
		Integer code=list!=null?ResultE.SUCCESS.getCode():ResultE.ERROR.getCode();
		dataResp.setData(list);
		dataResp.setCode(code);
		dataResp.setMes(mes);
		dataResp.setPageCount(counts);
		return dataResp;

	};



	public boolean update(Classinfo classinfo){
		return classdao.updatbyid(classinfo)>0;
	}

	public boolean delete(Classinfo classinfo){
		return classdao.deonebyid(classinfo)>0;
	}
	public boolean add(Classinfo classinfo){

		return classdao.addnew(classinfo)>0;
	}
}
